package s3_threadSafe;

public class Account {
    private String name;
    private String id;
    private double money;
    public Account(){}
    public Account(String id, double money)
    {
        this.id = id;
        this.money = money;
    }
    public void draw(double money)
    {
        String name1 = Thread.currentThread().getName();
        if(this.money >= money)
        {
            System.out.println(name1 + "取钱成功，取钱数目：" + money);
            this.money -= money;
            System.out.println(name1 +"余额：" + this.money);
        }
        else
        {
            System.out.println(name1 + "取钱失败，余额不足！");
        }
    }
}
